package com.breeze.components.task.lock;

import com.mybatisflex.core.row.Db;
import com.mybatisflex.spring.boot.MybatisFlexAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @author breeze
 */
@AutoConfiguration(after = MybatisFlexAutoConfiguration.class)
@ConditionalOnProperty(value = "breeze.distributed.lock.enable", havingValue = "true")
@ConditionalOnClass({Db.class})
@EnableConfigurationProperties(LockScheduleProperties.class)
public class ScheduleAutoConfig {

  @Bean
  public DistributedLockService distributedLockService() {
    return new DistributedLockService();
  }

  @Bean
  public LockScheduledAspect lockScheduledAspect() {
    return new LockScheduledAspect();
  }
}
